package strain.domain.interval_set_alt;

import java.util.ArrayList;
import java.util.Collection;

public class IntervalSetFactory<T extends Comparable<T>> {
    
    private final IntervalSet<T> universalSet;
    
    public IntervalSetFactory(final IntervalSet<T> universalSet){
        this.universalSet = universalSet;
    }
    
    public IntervalSet<T> complement(final IntervalSet<T> set){
        return set.complement(this.universalSet);
    }
    
    public IntervalSet<T> difference(final IntervalSet<T> subtrahend, final IntervalSet<T> minuend){
        return subtrahend.difference(minuend);
    }

    public IntervalSet<T> intersection(final IntervalSet<T> s1, final IntervalSet<T> s2){
        ArrayList<IntervalSet<T>> sets = new ArrayList<IntervalSet<T>>(2);
        sets.add(s1);
        sets.add(s2);
        return intersection(sets);
    }
    
    public IntervalSet<T> intersection(final Collection<IntervalSet<T>> sets){
        return IntervalSet.intersection(sets);
    }

    public IntervalSet<T> union(final IntervalSet<T> s1, final IntervalSet<T> s2){
        ArrayList<IntervalSet<T>> sets = new ArrayList<IntervalSet<T>>(2);
        sets.add(s1);
        sets.add(s2);
        return union(sets);
    }
    
    public IntervalSet<T> union(final Collection<IntervalSet<T>> sets){
        return IntervalSet.union(sets);
    }
    
    public IntervalSet<T> symmetricDifference(final IntervalSet<T> s1, final IntervalSet<T> s2){
        return s1.symmetricDifference(s2);
    }
    
}
